import javax.swing.*;
import java.awt.*;

public class GoBangFrame extends JFrame implements GoData {
    public int[][] chessArr;

    public void paint(Graphics g) {
        super.paint(g);
        //绘制棋盘
        for (int i = 0; i <= COL; i++) {
            g.drawLine(X,Y+i*SIZE,X+COL*SIZE,Y+i*SIZE);
            g.drawLine(X+i*SIZE,Y,X+i*SIZE,Y+ROW*SIZE);

        }
        //重绘棋子
        for (int i=0;i<chessArr.length; i++){
            for(int j=0;j<chessArr[i].length;j++){
                int cnum=chessArr[i][j]; //取出对应位置上的数字编号
                if(cnum!=0){
                    g.setColor(cnum==1?Color.BLACK:Color.WHITE);
                    int chessX = j*SIZE + X-SIZE/2;
                    int chessY = i*SIZE + Y-SIZE/2;
                    g.fillOval(chessX,chessY,SIZE,SIZE);
                }
            }

        }

    }
}


